package Filter;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

/**
 * @author hyacinth
 * @date 2023/5/16
 */
@WebFilter(urlPatterns = "/login")
public class FilterDemo implements Filter {
    @Override // 初始化
    public void init(FilterConfig filterConfig) throws ServletException {
        System.out.println("Filter初始化方法");
    }

    @Override // 拦截请求时就会调用
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        System.out.println("拦截了请求");
        filterChain.doFilter(servletRequest,servletResponse);
    }

    @Override // 销毁时
    public void destroy() {
        System.out.println("Filter销毁方法");
    }
}
